<?php
///关于标收费信息的统计
if(!isset($dbselect)) //前面没设置 数据库 则指定使用 DB3
    $dbselect   = Db::G3();
$sfwhere      = "";
if($startdate!="" && $enddate!=""){
    $sfwheref    = " and sf.repay_date>='$startdate' and  sf.repay_date<='$enddate'"; 
    $sfwheres    = " and sf.repay_yesdate>='$startdate' and  sf.repay_yesdate<='$enddate'"; 
} 
$rows = $dbselect->GetRows("SELECT b.cid,sf.repay_date '应还时间',sf.t_type as '收费类型',SUM(sf.money) AS '收费金额', COUNT(sf.money) AS '次数'
FROM 05b_2list_sf as sf left join 05b_0base  as b on sf.bid=b.bid 
WHERE sf.is_repay=0 $sfwheref
GROUP BY b.cid, sf.repay_date,t_type ");
foreach($rows as &$row)
{   
    $cid    = $row['cid'];
    $ctime  = $row['应还时间'];
    $Y      = date("Y", $ctime);
    $M      = date("n", $ctime);
    $D      = date("j", $ctime); 
    $count  = $row['次数'];
    CTLog::G()->pxxDayReal($count.",cid",$cid,"收费_应收_".$row['收费类型'],$row['收费金额'],$ctime);
}



$rows = $dbselect->GetRows("SELECT b.cid,sf.repay_yesdate '还款时间',sf.t_type as '收费类型',SUM(sf.money) AS '收费金额', COUNT(sf.money) AS '次数'
FROM 05b_2list_sf as sf left join 05b_0base  as b on sf.bid=b.bid 
WHERE sf.is_repay>0 $sfwheres
GROUP BY b.cid,sf.repay_yesdate,t_type ");
foreach($rows as &$row)
{   
    $cid    = $row['cid'];
    $ctime  = $row['还款时间'];
    $Y      = date("Y", $ctime);
    $M      = date("n", $ctime);
    $D      = date("j", $ctime); 
    $count  = $row['次数'];
    CTLog::G()->pxxDayReal($count.",cid",$cid,"收费_已收_".$row['收费类型'],$row['收费金额'],$ctime);
}

///全站数据

$rows = $dbselect->GetRows("SELECT b.cid,sf.repay_date '应还时间',sf.t_type as '收费类型',SUM(sf.money) AS '收费金额', COUNT(sf.money) AS '次数'
FROM 05b_2list_sf as sf left join 05b_0base  as b on sf.bid=b.bid 
WHERE sf.is_repay=0 $sfwheref
GROUP BY  sf.repay_date,t_type ");
foreach($rows as &$row)
{   
    $cid    = $row['cid'];
    $ctime  = $row['应还时间'];
    $Y      = date("Y", $ctime);
    $M      = date("n", $ctime);
    $D      = date("j", $ctime); 
    $count  = $row['次数'];
    CTLog::G()->pxxDayReal($count.",sid",1,"收费_应收_".$row['收费类型'],$row['收费金额'],$ctime);
}



$rows = $dbselect->GetRows("SELECT b.cid,sf.repay_yesdate '还款时间',sf.t_type as '收费类型',SUM(sf.money) AS '收费金额', COUNT(sf.money) AS '次数'
FROM 05b_2list_sf as sf left join 05b_0base  as b on sf.bid=b.bid 
WHERE sf.is_repay>0 $sfwheres
GROUP BY sf.repay_yesdate,t_type ");
foreach($rows as &$row)
{   
    $cid    = $row['cid'];
    $ctime  = $row['还款时间'];
    $Y      = date("Y", $ctime);
    $M      = date("n", $ctime);
    $D      = date("j", $ctime); 
    $count  = $row['次数'];
    CTLog::G()->pxxDayReal($count.",sid",1,"收费_已收_".$row['收费类型'],$row['收费金额'],$ctime);
}


//sunbin 标管理费
$rows = $dbselect->GetRows("SELECT b.cid,sf.repay_yesdate '还款时间',sf.t_type as '收费类型',SUM(sf.money) AS '收费金额', COUNT(sf.money) AS '次数'
FROM 05b_2list_sf as sf left join 05b_0base  as b on sf.bid=b.bid
WHERE sf.is_repay>0 $sfwheres
GROUP BY b.cid,sf.repay_yesdate ");
foreach($rows as &$row)
{
    $cid    = $row['cid'];
    $ctime  = $row['还款时间'];
    $Y      = date("Y", $ctime);
    $M      = date("n", $ctime);
    $D      = date("j", $ctime);
    $count  = $row['次数'];
    CTLog::G()->pxxDayReal($count.",cid",$cid,"网站_收费_标管理费",$row['收费金额'],$ctime);
}

///全站数据
$rows = $dbselect->GetRows("SELECT b.cid,sf.repay_yesdate '还款时间',sf.t_type as '收费类型',SUM(sf.money) AS '收费金额', COUNT(sf.money) AS '次数'
FROM 05b_2list_sf as sf left join 05b_0base  as b on sf.bid=b.bid
WHERE sf.is_repay=0 $sfwheres
GROUP BY  sf.repay_yesdate ");
foreach($rows as &$row)
{
    $cid    = $row['cid'];
    $ctime  = $row['还款时间'];
    $Y      = date("Y", $ctime);
    $M      = date("n", $ctime);
    $D      = date("j", $ctime);
    $count  = $row['次数'];
    CTLog::G()->pxxDayReal($count.",sid",1,"网站_收费_标管理费",$row['收费金额'],$ctime);
}